<template>
  <div class="container-fluid">
    <div class="row msg">
      <div class="col"></div>
    </div>
    <div class="row">
      <div class="col">
        <el-table height="100%" :data="tableData" border style="width: 100%" >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column fixed prop="ID" sortable label="ID" width="50"></el-table-column>
          <el-table-column fixed prop="name" label="名称" width="180"></el-table-column>
          <el-table-column prop="info" label="简介"></el-table-column>
          <el-table-column fixed="right" label="操作" width="200">
            <template slot-scope="scope">
              <router-link
                :to="{ name:'packageCourse1', params: { packageId: scope.row.ID },query: scope.row }"
                class="btn btn-sm btn-info"
                type="text"
                size="small"
              >查看</router-link>&nbsp;
              <router-link
                :to="{ name:'packageCourse2', params: { packageId: scope.row.ID },query: scope.row }"
                class="btn btn-sm btn-info"
                type="text"
                size="small"
              >序列号</router-link>&nbsp;
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import {
  asyncgetpasswordgroup,
  asyncdeletePackegeKeyByID
} from "../../../plugins/api.js";
export default {
  name: "watchpackage",
  data() {
    return {
      paths: [],
      name: "生成序列号",
      num1: 0,
      formLabelWidth: "120px",
      tableData: [
        {
          ID: 3,
          packegeInfo: "所有课程",
          packegeName: "课程包",
          prize: 0.1
        }
      ],
      upc: 0,
      form: {
        ID: "",
        packegeInfo: "",
        packegeName: "",
        prize: 0.1
      }
    };
  },
  async mounted() {
    this.start();
  },
  methods: {
    async start() {
      this.tableData = await asyncgetpasswordgroup();
    },
    couserindex() {
      return this.tableData[this.upc];
    },
    async deldata(i) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(async () => {
          try {
            await asyncdeletePackegeKeyByID(i);
            this.start();
            this.$message({
              message: "恭喜你，删除成功",
              type: "success"
            });
          } catch (err) {
            this.$message.error("错了哦，删除失败:" + err);
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    delpackage(i) {
      this.form.packegeid.splice(i, 1);
    },
    upcourseshow(i) {
      this.form = this.tableData[i];
    }
  }
};
</script>

<style scoped>
</style>